﻿package  {
	import flash.display.Sprite;
	import flash.events.TimerEvent;
	import flash.geom.Point;
	import flash.utils.Timer;
	import com.kerry.effect.Light;
	
	/**
	 * com.kerry.effect.Light 类的演示文件
	 * @author PhoenixKerry（http://blog.sina.com.cn/yyy98）
	 */
	public class LightDemo extends Sprite {
		
		public function LightDemo() {
			thunderStorm();
		}
		
		/**
		 * 闪电暴效果
		 */
		private function thunderStorm():void {
			// 每隔 200 毫秒产生一道闪电
			var thunderTimer:Timer = new Timer(200);
			thunderTimer.start();
			thunderTimer.addEventListener(TimerEvent.TIMER, thunderOut);
		}
		
		private function thunderOut(e:TimerEvent):void {
			var startPoint:Point = new Point(Math.random() * stage.stageWidth, 0);
			var endPoint:Point = new Point(Math.random() * stage.stageWidth, Math.random() * stage.stageHeight);
			var light:Light = new Light(startPoint, endPoint, 2);
			addChild(light);
		}
		
	}
}